package com.hspedu.try_;

import java.util.Scanner;

/**
 * @author DL5O
 * @version 1.0
 */
public class TryCatchExercise {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = "";
        int num = 0;
        System.out.print("请输入一个整数：");

        while(true){
            str =sc.next();
            try {
                num = Integer.parseInt(str);
                break;
            } catch (NumberFormatException e) {
                System.out.print("输入有误，请重新输入：");
            }
        }
        System.out.println("您输入的整数为："+num);

    }
}
